package chapter03;


/**
 * 用数组反转字符串
 * Created by a on 2017/6/9.
 */
public class Test049 {
    public static void main(String[] args) {


        //使用StringBuilder.reverse（）反转字符串
        StringBuilder stringBuilder = new StringBuilder("abcd");
        System.out.println(stringBuilder.reverse());

        //自定义字符串反转算法
        String string = "qwertyuiop";
        char[] chars = string.toCharArray();
        String str = "反转字符串:";
        for (int i =0;i<chars.length/2;i++){
            char temp = chars[i];
            chars[i] = chars[chars.length-i-1];
            chars[chars.length-i-1] = temp;
        }
        String string1 = new String(chars);
        System.out.println(string1);



    }
}
